# @Filename:    operate_xls.py
# @Author:      王佳伟
# @Time:        2025-07-21 13:59
# @Describe:    Pandas Excel读写操作
import pandas as pd

# to_excel()
# 创建DataFrame对象
# info_website = pd.DataFrame({
#     'name':['编程帮', 'c语言中文网', '微学苑', '92python'],
#     'rank':[1,2,3,4],
#     'language':['PHP','C','PHP','Python'],
#     'url':['www.bianchneg.com', 'c.bianchneg.net', 'www.weixueyuan.com','www.92python.com']
# })
# 创建ExcelWrite对象
# writer = pd.ExcelWriter('website.xlsx')
# info_website.to_excel(writer)
# writer._save()
# print('输出成功')

# read_excel() 读取Excel表格中的数据
df = pd.read_excel('website.xlsx',index_col='name',skiprows=[2])
# 处理未命名列
df.columns = df.columns.str.replace('Unnamed.*', 'col_label')
print(df)

